

#ifndef __DONGLEKEY_H__
#define __DONGLEKEY_H__

#include "types.h"
#include "gpio.h"

#define KEY_NUM 1

typedef enum
{
    STATE_KEY_IDLE = 0x00,
    STATE_KEY_PRESS_DEBONCE = 0x01,
    STATE_KEY_PRESS = 0x02,
    STATE_KEY_RELEASE_DEBONCE = 0x03,
} key_state_e;

typedef enum
{
    TOUCH_EVT_PRESS   = 0x01,
    TOUCH_EVT_RELEASE,
    TOUCH_EVT_SHORT_PRESS,
    TOUCH_EVT_LONG_PRESS,
} key_evt_t;

typedef void (* key_callbank_hdl_t)(key_evt_t,uint8);

typedef struct key_state
{
    uint32_t timer_tick[KEY_NUM];
    uint8    state[KEY_NUM];
    bool     in_enable[KEY_NUM];
    key_callbank_hdl_t key_callbank;
} key_contex_t;

typedef struct key_pin
{
    GpioPin_t pin[KEY_NUM];
} key_pin_t;


int dongleKey_init(key_callbank_hdl_t hdl);
void gpio_key_timer_handler(uint8 index);

#endif
